<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>门诊记录详情</title>
    <%- include('../_global/baseLibsJKDA') %>
        <!--<script src="@{/scripts/common/quick-cache.js}"></script>-->
        <link rel="stylesheet" href="/static/css/jkda/page-main.css" />
        <script src="/static/js/jkda/jkda-zy-jclx.js}"></script>
        <script src="/static/js/<%=type%>/pageUrl.js"></script>
        <script src="/static/js/<%=type%>/jkda.js"></script>
        <style type="text/css">
            html,
            body {
                width: 100%;
                height: 100%;
                margin: 0px;
            }

            tr td {
                padding: 0.71429rem 0.71429rem;
                font-size: 0.85714rem;
                color: #7a7a7a;
                word-break: break-all;
            }
        </style>


        <script type="text/javascript">
            function appendToJyxx(JYXX) {
                console.log(JYXX);
                var trs = [];
                if (JYXX) {
                    var ywzys = JYXX.split("}|{");
                    for (var i = 0; i < ywzys.length; i++) {
                        if (ywzys[i]) {
                            var bgzy = ywzys[i].split("&|&");
                            var bgzys = bgzy[0].split("^|^");
                            var tr = $("<tr>");
                            tr.attr("class", "row");
                            var td1 = $("<td>");
                            td1.attr("class", "col-xs-5");
                            td1.html(bgzys[1]);
                            td1.appendTo(tr);
                            var td2 = $("<td>");
                            td2.attr("class", "col-xs-5");
                            td2.html(bgzys[0]);
                            td2.appendTo(tr);
                            var td5 = $("<td>");
                            td5.attr("class", "col-xs-2");
                            td5.html("<a  >查看</a>");
                            td5.data("content", ywzys[i]);
                            td5.attr("onclick", "jyResultBtn(this)");
                            td5.appendTo(tr);

                            trs.push(tr);
                        }
                    }
                } else {
                    var tr = $("<tr>");
                    var td = $("<td>");
                    td.attr("colspan", "4");
                    td.attr("style", "width:100%;text-align:center; font-weight:bold;color:#000;");
                    td.html("暂无信息");
                    td.appendTo(tr);
                    trs.push(tr);
                }
                $("#Jyxx").append(trs);
            }

            var page_mzDetail = (function ($, page_mzDetail) {


                var cfg_def = {
                    indata: indata,
                    callBack: callBack,
                    arrayToString: arrayToString,
                    appendToMzxx: appendToMzxx,
                    appendToYpxx: appendToYpxx,
                    appendToJcxx: appendToJcxx,
                    appendToJyxx,appendToJyxx
                }

                page_mzDetail.init = function (cfg) {
                    $.extend(page_mzDetail, cfg_def, cfg);
                    page_mzDetail.indata();

                }

                return page_mzDetail;

                function indata() {
                    var EID = $.JkdaUtils.decryptStr("fjzlyd-jkda-yddy", $.QuickUrlUtils.getRequest("JKDAEID"));
                    var zxwyh = $.QuickUrlUtils.getRequest("ZXWYH");
                    $.QuickRemote.AjaxJson(goal_jkda_service + "/jkda/queryDetailBg", page_mzDetail.callBack, {
                        EID: EID,
                        TYPE: "MZ",
                        ZXWYH: zxwyh
                    });
                }

                function callBack(result) {

                    //解析result
                    var MZXXS = [];
                    var YPXXS = [];
                    var JCXXS = [];
                    var JYXXS = [];
                    $(result).each(function () {
                        var bglx = this["BGLX"];
                        if (bglx == "C0001.0201") {
                            MZXXS.push(this["BGZY"]);
                        } else if (bglx == "C0001.0502") {
                            YPXXS.push(this["BGZY"]);
                        } else if (bglx == "C0001.0305") {
                            JCXXS.push(this["BGZY"]);
                        } else if (bglx == "C0001.0303c" || bglx == "C0001.0303d" || bglx ==
                            "C0001.0303b") {
                            JYXXS.push(this["BGZY"]);
                        }
                    });

                    var MZXX = page_mzDetail.arrayToString(MZXXS);
                    var YPXX = page_mzDetail.arrayToString(YPXXS);
                    var JCXX = page_mzDetail.arrayToString(JCXXS);
                    var JYXX = page_mzDetail.arrayToString(JYXXS);


                    page_mzDetail.appendToMzxx(MZXX);
                    page_mzDetail.appendToYpxx(YPXX);
                    page_mzDetail.appendToJcxx(JCXX);
                    page_mzDetail.appendToJyxx(JYXX);
                }

                function arrayToString(arr) {
                    var str = "";
                    for (var i = 0; i < arr.length; i++) {
                        str = str + arr[i];
                    }
                    return str;
                }


                function appendToMzxx(MZXX) {
                    var trs = [];
                    if (MZXX) {
                        var bgzys = MZXX.split("^|^");
                        var p1 = $("<p>");
                        p1.html("医院：");
                        var span1 = $("<span>");
                        span1.html(bgzys[1]);
                        span1.appendTo(p1);
                        trs.push(p1);

                        var p2 = $("<p>");
                        p2.html("就诊时间：");
                        var span2 = $("<span>");
                        var str;
                        var date;
                        if (StringUtils.isEmpty(bgzys[0])) {
                            str = bgzys[0];
                        } else {
                            date = new Date(bgzys[0].replace(/(\d{4})(\d{2})(\d{2})/g, '$1-$2-$3'));
                            str = date.Format("yyyy-MM-dd");
                        }
                        span2.html(str);
                        span2.appendTo(p2);
                        trs.push(p2);

                        var p3 = $("<p>");
                        p3.html("就诊科室：");
                        var span3 = $("<span>");
                        span3.html(bgzys[2]);
                        span3.appendTo(p3);
                        trs.push(p3);
                        /* var tr2 = $("<tr>");
                        var td4 = $("<td>");
                        td4.attr("colspan","2");
                        td4.html("诊断：" + bgzys[8]);
                        td4.appendTo(tr2);
                        trs.push(tr2); */
                    } else {
                        var tr = $("<div>");
                        tr.attr("style", "width:100%;text-align:center; font-weight:bold;color:#000;");
                        tr.html("暂无信息");
                        trs.push(tr);
                    }
                    $("#Mzxx").append(trs);
                }

                function appendToYpxx(YPXX) {
                    var trs = [];
                    if (YPXX) {
                        var ywzys = YPXX.split("}|{");
                        for (var i = 0; i < ywzys.length; i++) {
                            var ypxx = ywzys[i].split("^|^");
                            var tr = $("<tr>");
                            tr.attr("class", "row");
                            var td1 = $("<td>");
                            td1.attr("class", "col-xs-3");
                            td1.html(ypxx[0]);
                            td1.appendTo(tr);
                            var td2 = $("<td>");
                            td2.attr("class", "col-xs-3");
                            td2.html(ypxx[3]);
                            td2.appendTo(tr);
                            var td3 = $("<td>");
                            td3.attr("class", "col-xs-2");
                            td3.html(ypxx[7]);
                            td3.appendTo(tr);
                            var td4 = $("<td>");
                            td4.attr("class", "col-xs-2");
                            td4.html(ypxx[8] + ypxx[9]);
                            td4.appendTo(tr);
                            var td5 = $("<td>");
                            td5.attr("class", "col-xs-2");
                            td5.html(ypxx[4] + ypxx[5]);
                            td5.appendTo(tr);
                            trs.push(tr);
                        }
                    } else {
                        var tr = $("<tr>");
                        var td = $("<td>");
                        td.attr("colspan", "6");
                        td.attr("style", "width:100%;text-align:center; font-weight:bold;color:#000;");
                        td.html("暂无信息");
                        td.appendTo(tr);
                        trs.push(tr);
                    }
                    $("#Ypxx").append(trs);
                }

                function appendToJcxx(JCXX) {
                    var trs = [];
                    if (JCXX) {
                        var ywzys = JCXX.split("}|{");
                        for (var i = 0; i < ywzys.length; i++) {
                            if (ywzys[i]) {
                                var bgzys = ywzys[i].split("^|^");

                                var tr = $("<tr>");
                                tr.attr("class", "row");
                                var td1 = $("<td>");
                                td1.attr("class", "col-xs-3");
                                td1.html($.JkdaJclxZy.getValue(bgzys[0]));
                                //						td1.html(bgzys[0]);
                                td1.appendTo(tr);
                                /* var td2 = $("<td>");
                                td2.html(bgzys[1]);
                                td2.appendTo(tr); */
                                var td3 = $("<td>");
                                td3.attr("class", "col-xs-3");
                                td3.html(bgzys[2]);
                                td3.appendTo(tr);
                                var td4 = $("<td>");
                                td4.attr("class", "col-xs-3");
                                td4.html(bgzys[3]);
                                td4.appendTo(tr);
                                var td5 = $("<td>");
                                td5.attr("class", "col-xs-3");
                                td5.html("<a  >查看</a>");
                                //将数据放入data
                                td5.data("content", ywzys[i]);
                                td5.attr("onclick", "jcResultBtn(this)");
                                td5.appendTo(tr);

                                trs.push(tr);

                            }
                        }
                    } else {
                        var tr = $("<tr>");
                        var td = $("<td>");
                        td.attr("colspan", "5");
                        td.attr("style", "width:100%;text-align:center; font-weight:bold;color:#000;");
                        td.html("暂无信息");
                        td.appendTo(tr);
                        trs.push(tr);
                    }
                    $("#Jcxx").append(trs);
                }
            })(jQuery, {});



            function jcResultBtn(p) {
                var content = $(p).data("content");
                StoreCache.setCache("searchContent", content + "^|^jc");
                $.QuickUrlUtils.redirectJSBridge({
                    url: jkda_view + "/jzjl/JcDetail.html",
                    title: "检查单详情"
                });
            }

            function jyResultBtn(p) {
                var content = $(p).data("content");
                StoreCache.setCache("searchContent", content + "^|^jy");
                $.QuickUrlUtils.redirectJSBridge({
                    url: jkda_view + "/jzjl/jcDetail.html",
                    title: "检验单详情"
                });
                //        jybgxq.html?from=report&zxwyh=330521201704220017&reportId=47122054433052111A100120171205G003307920171205
            }
        </script>
</head>

<body>
    <section class="page-clinic-details">
        <input type="hidden" class="quickCache" cacheTable="TB_ZY_JKDA_JCLX">
        <ul class="detail">
            <li class="t-box">
                <i class="detail-icon j-1"></i>
                <h3>门诊信息</h3>
                <div id="Mzxx">

                </div>
            </li>
            <li class="b-box">
                <i class="detail-icon j-2"></i>
                <h3>药品信息</h3>
                <table>
                    <thead>
                        <tr class="row">
                            <th class="col-xs-3">药品名称</th>
                            <th class="col-xs-3">用法</th>
                            <th class="col-xs-2">频次</th>
                            <th class="col-xs-2">用量</th>
                            <th class="col-xs-2">数量</th>
                        </tr>
                    </thead>
                    <tbody id="Ypxx">
                    </tbody>
                </table>
            </li>
            <li class="b-box">
                <i class="detail-icon j-3"></i>
                <h3>检查信息</h3>
                <table>
                    <thead>
                        <tr class="row">
                            <th class="col-xs-3">检查类型</th>
                            <th class="col-xs-3">检查部位</th>
                            <th class="col-xs-3">检查名称</th>
                            <th class="col-xs-3">结果</th>
                        </tr>
                    </thead>
                    <tbody id="Jcxx">

                    </tbody>
                </table>
            </li>
            <li class="b-box">
                <i class="detail-icon j-4"></i>
                <h3>检验信息</h3>
                <table>
                    <thead>
                        <tr class="row">
                            <th class="col-xs-5">报告单类别</th>
                            <th class="col-xs-5">检验标本</th>
                            <th class="col-xs-2">结果</th>
                        </tr>
                    </thead>
                    <tbody id="Jyxx">

                    </tbody>
                </table>
            </li>
        </ul>
    </section>
</body>

</html>